{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "1c5d2271",
   "metadata": {},
   "source": [
    "----\n",
    "* 2022/10/18 week09  \n",
    "----"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "10d45d0c",
   "metadata": {},
   "source": [
    "# 本周知识点  \n",
    "> 1.while循环  \n",
    "> 2.购物车练习  \n",
    "> 3.元组_集合"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "05e6bfee",
   "metadata": {},
   "source": [
    "## 1.while循环--死循环"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "918b68f5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "你是风儿我是沙，缠缠绵绵到天涯... 0\n",
      "你是风儿我是沙，缠缠绵绵到天涯... 1\n",
      "你是风儿我是沙，缠缠绵绵到天涯... 2\n",
      "你是风儿我是沙，缠缠绵绵到天涯... 3\n",
      "你是风儿我是沙，缠缠绵绵到天涯... 4\n"
     ]
    }
   ],
   "source": [
    "# while Ture 可以实现for + range 的方式\n",
    "# while Ture 一般用于不确定的循环或者无限次循环操作。\n",
    "\n",
    "count = 0\n",
    "while True:\n",
    "    print(\"你是风儿我是沙，缠缠绵绵到天涯...\",count)\n",
    "    count +=1\n",
    "    if count == 5:  ## 循环5次停止\n",
    "        break\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "c4fcbf38",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hide_card:········\n",
      "游戏开始\n",
      "guess_digit8\n",
      "往大了猜\n",
      "guess_digit99\n",
      "猜对了\n"
     ]
    }
   ],
   "source": [
    "import getpass\n",
    "hide_card = int(getpass.getpass(\"hide_card:\"))  ## 隐藏输入的东西\n",
    "count = 0\n",
    "\n",
    "if hide_card <100 and hide_card >0 :\n",
    "    print(\"游戏开始\")\n",
    "    while True:\n",
    "        if count <5:  ## count>5 时游戏结束\n",
    "            guess_digit = int(input(\"guess_digit\"))  ## 猜数字的人\n",
    "            if guess_digit == hide_card:\n",
    "                print(\"猜对了\")\n",
    "                break  ## 猜对后停止\n",
    "            elif guess_digit > hide_card:\n",
    "                print(\"往小了猜\")\n",
    "            else:\n",
    "                print(\"往大了猜\")\n",
    "            count = count+1\n",
    "        else:\n",
    "            print(\"猜那么多次都不对，你个sb\")\n",
    "            print(\"正确答案是：%s\"%hide_card)  ## 打印正确答案\n",
    "            break\n",
    "else:\n",
    "    print(\"输入范围为0-99\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9ff59abe",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
